package com.top75;

import com.bean.ListNode;

/**
 * @Author: huangzhigao
 * @Date: 2023/5/22 20:29
 */
public class Code2130 {
    public int pairSum(ListNode head){
        int length = 0;
        ListNode cur = head;
        while (cur!=null){
            cur = cur.next;
            length++;
        }

        int[] doubles = new int[length];
        int res = 0;
        ListNode cur1 = head;
        int i =0;
        while (cur1!=null){
            doubles[i++] = cur1.val;
            cur1 = cur1.next;
        }
        int left = 0;
        int right = length-1;
        while (left<right){
            res = Math.max(res,doubles[left++]+doubles[right--]);
        }
        return res;

    }
}
